package spring.j2024_11_17_2.mvc;


import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.SessionAttribute;

import javax.servlet.http.HttpSession;

@RequestMapping("/mvc")
@RestController
public class Mvc1 {
    @RequestMapping("/set")
    public String set(HttpSession session){
        session.setAttribute("name","zhangsan");
        return "设置session成功";
    }
     @RequestMapping("/s1")
    public String s1(@SessionAttribute(value = "name" , required = false) String name){
        return "name:"+name ;
    }
    @RequestMapping("/m1")
    public String m1(@RequestParam("a1") int num){
        return "a1 "+ num ;
    }

}
